class HelmetModel{
  HelmetCounts? counts;
  List<HelmetPhotos>? photos;
  List<HelmetReaders>? readers;
  List<AlertEvents>? alertEvents;

  HelmetModel({this.counts, this.photos, this.readers, this.alertEvents});

  HelmetModel.fromJson(Map<String, dynamic> json) {
    counts =
    json['counts'] != null ? new HelmetCounts.fromJson(json['counts']) : null;
    if (json['photos'] != null) {
      photos = <HelmetPhotos>[];
      json['photos'].forEach((v) {
        photos!.add(new HelmetPhotos.fromJson(v));
      });
    }
    if (json['readers'] != null) {
      readers = <HelmetReaders>[];
      json['readers'].forEach((v) {
        readers!.add(new HelmetReaders.fromJson(v));
      });
    }
    if (json['alertEvents'] != null) {
      alertEvents = <AlertEvents>[];
      json['alertEvents'].forEach((v) {
        alertEvents!.add(new AlertEvents.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.counts != null) {
      data['counts'] = this.counts!.toJson();
    }
    if (this.photos != null) {
      data['photos'] = this.photos!.map((v) => v.toJson()).toList();
    }
    if (this.readers != null) {
      data['readers'] = this.readers!.map((v) => v.toJson()).toList();
    }
    if (this.alertEvents != null) {
      data['alertEvents'] = this.alertEvents!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class HelmetCounts {
  int? sosTotal;
  int? antiCollTotal;
  int? dangerZoneTotal;

  HelmetCounts({this.sosTotal, this.antiCollTotal, this.dangerZoneTotal});

  HelmetCounts.fromJson(Map<String, dynamic> json) {
    sosTotal = json['sosTotal'];
    antiCollTotal = json['antiCollTotal'];
    dangerZoneTotal = json['dangerZoneTotal'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['sosTotal'] = this.sosTotal;
    data['antiCollTotal'] = this.antiCollTotal;
    data['dangerZoneTotal'] = this.dangerZoneTotal;
    return data;
  }
}

class HelmetPhotos {
  String? deviceCode;
  String? deviceName;
  String? photo;
  DateTime? portalOWAt;

  HelmetPhotos({this.deviceCode, this.deviceName, this.photo, this.portalOWAt});

  HelmetPhotos.fromJson(Map<String, dynamic> json) {
    deviceCode = json['deviceCode'];
    deviceName = json['deviceName'];
    photo = json['photo'];
    portalOWAt =
    json['portalOWAt'] != null ? DateTime.tryParse(json['portalOWAt']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['deviceCode'] = this.deviceCode;
    data['deviceName'] = this.deviceName;
    data['photo'] = this.photo;
    data['portalOWAt'] = this.portalOWAt;
    return data;
  }
}

class HelmetReaders {
  String? id;
  String? code;
  String? name;
  double? lat;
  double? lng;
  int? state;
  String? stateName;
  String? readerIcon;

  HelmetReaders(
      {this.id,
        this.code,
        this.name,
        this.lat,
        this.lng,
        this.state,
        this.stateName,
        this.readerIcon});

  HelmetReaders.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    code = json['code'];
    name = json['name'];
    lat = json['lat'];
    lng = json['lng'];
    state = json['state'];
    stateName = json['stateName'];
    readerIcon = json['readerIcon'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['code'] = this.code;
    data['name'] = this.name;
    data['lat'] = this.lat;
    data['lng'] = this.lng;
    data['state'] = this.state;
    data['stateName'] = this.stateName;
    data['readerIcon'] = this.readerIcon;
    return data;
  }
}

class AlertEvents {
  String? alertName;
  String? alertAt;
  String? reason;

  AlertEvents({this.alertName, this.alertAt, this.reason});

  AlertEvents.fromJson(Map<String, dynamic> json) {
    alertName = json['alertName'];
    alertAt = json['alertAt'];
    reason = json['reason'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['alertName'] = this.alertName;
    data['alertAt'] = this.alertAt;
    data['reason'] = this.reason;
    return data;
  }
}